package org.wen.soft.generate.util;

import org.objectweb.asm.Type;
import org.springframework.util.StringUtils;
import java.util.ArrayList;
import java.util.List;

public class GStrUtil {


    public static String simpleName(String className){
        int lastIndexOf = className.lastIndexOf(".");
        return className.substring(lastIndexOf + 1).replace("$", ".");
    }

    public static String classTypeName(String className){
        return className.replace("$", ".");
    }

    public static String testFileSimpleName(String simpleName){
        return simpleName.replace(".", "") + "Test";
    }

    public static String packageName(String className){
        int lastIndexOf = className.lastIndexOf(".");
        return className.substring(0, lastIndexOf);
    }

    public static String varName(String simpleName) {
        // uncapitalize 首字母小写， capitalize首字母大写
        return StringUtils.uncapitalize(simpleName.replace(".", ""));
    }

    public static String descriptorClassName(String descriptor) {
        Type type = Type.getType(descriptor);
        return type.getClassName();
    }

}
